package com.zhuoyue.system.service.impl;


import com.zhuoyue.common.core.domain.BatchResultDTO;
import com.zhuoyue.common.core.domain.ResultDTO;
import com.zhuoyue.common.core.domain.TblCountAndTimeDO;
import com.zhuoyue.common.core.domain.TblReportFormsDO;
import com.zhuoyue.common.enums.ResultCode;
import com.zhuoyue.system.domain.vo.TblReportFormsVo;
import com.zhuoyue.system.mapper.TblMessageMapper;
import com.zhuoyue.system.mapper.TblReportFormsMapperDao;
import com.zhuoyue.system.mapper.TblSecurityLogMapper;
import com.zhuoyue.system.service.TblReportFormsService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.util.List;


import static com.zhuoyue.common.enums.RootCode.ORGCODE;

/**
 * ClassName: TblReportFormsServiceImpl <br/>
 * Description: <br/>
 * date: 2019/5/29 12:00<br/>
 *
 * @author wjming<br />
 * @version 1.0
 */
@Service("tblReportFormsService")
//@DataSource(SLAVE)
public class TblReportFormsServiceImpl implements TblReportFormsService {
    @Autowired
    TblReportFormsMapperDao tblReportFormsMapperDao;
    @Autowired
    private TblMessageMapper tblMessageMapper;
    @Autowired
    private TblSecurityLogMapper tblSecurityLogMapper;

    @Override
    public ResultDTO getUserAndDeviceAndGatewayAndMessageCount(String orgCode, TblReportFormsVo tblReportFormsBO) {
        ResultDTO resultDTO = new ResultDTO();
        try {
            TblReportFormsDO tblReportFormsDO = null;
            if (ORGCODE.equals(orgCode)) {
                tblReportFormsDO = tblReportFormsMapperDao.selectUserAndDeviceAndGatewayAndMessageCountByJiZi();
            } else {
                //记得这里还要加上wifi设备查询并且要两个相加
                tblReportFormsDO = tblReportFormsMapperDao.selectUserAndDeviceAndGatewayAndMessageCount(tblReportFormsBO);
            }

            if (tblReportFormsDO == null) {
                resultDTO.setSuccess(false);
                resultDTO.setErrorDetail("查询出错");
                resultDTO.setResultCode(ResultCode.PARAM_ERROR);
                return resultDTO;
            }
            resultDTO.setSuccess(true);
            resultDTO.setModule(tblReportFormsDO);
            resultDTO.setResultCode(ResultCode.SUCCESS);
        } catch (Exception e) {
            System.out.println("数据统计异常信息e = " + e);
            resultDTO.setSuccess(false);
            resultDTO.setErrorDetail("查询出错");
            resultDTO.setResultCode(ResultCode.FAIL);
            return resultDTO;
        }
        return resultDTO;
    }

    /**
     * 获取用户报表数据
     *
     * @param orgCode
     * @return
     */
    @Override
    public ResultDTO getUserReportFormsData(String type, String time, String orgCode) {
        ResultDTO resultDTO = new ResultDTO();
        List<TblCountAndTimeDO> tblCountAndTimeDOS = null;
        try {

            tblCountAndTimeDOS = ReportFormsFuncation(type, time, orgCode);

            resultDTO.setSuccess(true);
            resultDTO.setResultCode(ResultCode.SUCCESS);
            resultDTO.setModule(tblCountAndTimeDOS);
        } catch (Exception e) {
            System.out.println("getUserReportFormsData e = " + e);
            resultDTO.setSuccess(false);
            resultDTO.setErrorDetail("查询系统异常");
            resultDTO.setResultCode(ResultCode.FAIL);
            return resultDTO;
        }
        return resultDTO;
    }

    /**
     * @param type    指的是用户，还是设备还是报警信息，还是消息，还是网关
     * @param time
     * @param orgCode
     * @return
     */
    private List<TblCountAndTimeDO> ReportFormsFuncation(String type, String time, String orgCode) {
        //查询数据库表名

        List<String> meTableList = this.tblMessageMapper.selectTableName();
        List<String> seTableList = this.tblSecurityLogMapper.selectTableName();

        List<TblCountAndTimeDO> tblCountAndTimeDOS = null;
        try {
            switch (type) {
                case "user":
                    switch (time) {
                        case "day1":
                            if (ORGCODE.equals(orgCode)) {
                                tblCountAndTimeDOS = tblReportFormsMapperDao.selectAppUseEveryDay("");
                                if (CollectionUtils.isEmpty(tblCountAndTimeDOS)) {
                                }
                            } else {
                                TblReportFormsVo tblReportFormsBO = new TblReportFormsVo();
                                tblReportFormsBO.setOrganizationCode(orgCode);
                                tblCountAndTimeDOS = tblReportFormsMapperDao.selectAppUseEveryDayByOrgCode(tblReportFormsBO);
                                if (CollectionUtils.isEmpty(tblCountAndTimeDOS)) {

                                }
                            }
                            break;
                        case "week":
                            if (ORGCODE.equals(orgCode)) {
                                tblCountAndTimeDOS = tblReportFormsMapperDao.selectAppUseEveryWeek("");
                                if (CollectionUtils.isEmpty(tblCountAndTimeDOS)) {
//                                resultDTO.setSuccess(false);
//                                resultDTO.setErrorDetail("查询每周注册用户量失败");
//                                resultDTO.setResultCode(ResultCode.PARAM_ERROR);
//                                return resultDTO;
                                }
                            } else {
                                TblReportFormsVo tblReportFormsBO = new TblReportFormsVo();
                                tblReportFormsBO.setOrganizationCode(orgCode);
                                tblCountAndTimeDOS = tblReportFormsMapperDao.selectAppUseEveryWeekByOrgCode(tblReportFormsBO);
                                if (CollectionUtils.isEmpty(tblCountAndTimeDOS)) {
//                                resultDTO.setSuccess(false);
//                                resultDTO.setErrorDetail("查询每周注册用户量失败");
//                                resultDTO.setResultCode(ResultCode.PARAM_ERROR);
//                                return resultDTO;
                                }
                            }
                            break;
                        case "month":

                            //获取月的用户量
                            if (ORGCODE.equals(orgCode)) {
                                tblCountAndTimeDOS = tblReportFormsMapperDao.selectAppUseEveryMonth("");
                                if (CollectionUtils.isEmpty(tblCountAndTimeDOS)) {
//                                resultDTO.setSuccess(false);
//                                resultDTO.setErrorDetail("查询每月注册用户量失败");
//                                resultDTO.setResultCode(ResultCode.PARAM_ERROR);
//                                return resultDTO;
                                }
                            } else {
                                TblReportFormsVo tblReportFormsBO = new TblReportFormsVo();
                                tblReportFormsBO.setOrganizationCode(orgCode);
                                tblCountAndTimeDOS = tblReportFormsMapperDao.selectAppUseEveryMonthByOrgCode(tblReportFormsBO);
                                if (CollectionUtils.isEmpty(tblCountAndTimeDOS)) {
//                                resultDTO.setSuccess(false);
//                                resultDTO.setErrorDetail("查询每月注册用户量失败");
//                                resultDTO.setResultCode(ResultCode.PARAM_ERROR);
//                                return resultDTO;
                                }
                            }
                            break;
                        default:
                            if (StringUtils.isNotEmpty(time)) {
                                String[] timeStr = time.split("~");
                                String startTime = timeStr[0] + " 00:00:00";
                                String endTime = timeStr[1] + " 23:59:59";
//                                SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//                                Date date1=format.parse(startTime);
//                                Date date2=format.parse(endTime);
//                                //转换为Date类
//                                Long timestamp1=date1.getTime();
//                                Long timestamp2=date2.getTime();

                                if (ORGCODE.equals(orgCode)) {
                                    tblCountAndTimeDOS = tblReportFormsMapperDao.selectAppUseByTime(startTime, endTime);

                                } else {
                                    TblReportFormsVo tblReportFormsBO = new TblReportFormsVo();
                                    tblReportFormsBO.setOrganizationCode(orgCode);
                                    tblReportFormsBO.setStartTime(startTime);
                                    tblReportFormsBO.setEndTime(endTime);
                                    tblCountAndTimeDOS = tblReportFormsMapperDao.selectAppUseByTimeAndOrgCode(tblReportFormsBO);

                                }
                            }
                            break;
                    }
                    break;
                case "device":
                    switch (time) {
                        case "day1":
                            if (ORGCODE.equals(orgCode)) {
                                tblCountAndTimeDOS = tblReportFormsMapperDao.selectDeviceEveryDay("");
                                if (CollectionUtils.isEmpty(tblCountAndTimeDOS)) {
                                }
                            } else {
                                TblReportFormsVo tblReportFormsBO = new TblReportFormsVo();
                                tblReportFormsBO.setOrganizationCode(orgCode);
                                tblReportFormsBO.setRelationType("0");
                                tblCountAndTimeDOS = tblReportFormsMapperDao.selectDeviceEveryDayByOrgCode(tblReportFormsBO);
                                if (CollectionUtils.isEmpty(tblCountAndTimeDOS)) {

                                }
                            }
                            break;
                        case "week":
                            if (ORGCODE.equals(orgCode)) {
                                tblCountAndTimeDOS = tblReportFormsMapperDao.selectDeviceEveryWeek("");
                                if (CollectionUtils.isEmpty(tblCountAndTimeDOS)) {
//                                resultDTO.setSuccess(false);
//                                resultDTO.setErrorDetail("查询每周注册用户量失败");
//                                resultDTO.setResultCode(ResultCode.PARAM_ERROR);
//                                return resultDTO;
                                }
                            } else {
                                TblReportFormsVo tblReportFormsBO = new TblReportFormsVo();
                                tblReportFormsBO.setOrganizationCode(orgCode);
                                tblReportFormsBO.setRelationType("0");
                                tblCountAndTimeDOS = tblReportFormsMapperDao.selectDeviceEveryWeekByOrgCode(tblReportFormsBO);
                                if (CollectionUtils.isEmpty(tblCountAndTimeDOS)) {
//                                resultDTO.setSuccess(false);
//                                resultDTO.setErrorDetail("查询每周注册用户量失败");
//                                resultDTO.setResultCode(ResultCode.PARAM_ERROR);
//                                return resultDTO;
                                }
                            }
                            break;
                        case "month":

                            //获取月的设备数量
                            if (ORGCODE.equals(orgCode)) {
                                tblCountAndTimeDOS = tblReportFormsMapperDao.selectDeviceEveryMonth("");
                                if (CollectionUtils.isEmpty(tblCountAndTimeDOS)) {
//                                resultDTO.setSuccess(false);
//                                resultDTO.setErrorDetail("查询每月注册用户量失败");
//                                resultDTO.setResultCode(ResultCode.PARAM_ERROR);
//                                return resultDTO;
                                }
                            } else {
                                TblReportFormsVo tblReportFormsBO = new TblReportFormsVo();
                                tblReportFormsBO.setOrganizationCode(orgCode);
                                tblReportFormsBO.setRelationType("0");
                                tblCountAndTimeDOS = tblReportFormsMapperDao.selectDeviceEveryMonthByOrgCode(tblReportFormsBO);
                                if (CollectionUtils.isEmpty(tblCountAndTimeDOS)) {
//                                resultDTO.setSuccess(false);
//                                resultDTO.setErrorDetail("查询每月注册用户量失败");
//                                resultDTO.setResultCode(ResultCode.PARAM_ERROR);
//                                return resultDTO;
                                }
                            }
                            break;
                        default:
                            if (StringUtils.isNotEmpty(time)) {
                                String[] timeStr = time.split("~");
                                String startTime = timeStr[0] + " 00:00:00";
                                String endTime = timeStr[1] + " 23:59:59";
                                if (ORGCODE.equals(orgCode)) {
                                    tblCountAndTimeDOS = tblReportFormsMapperDao.selectDeviceByTime(startTime, endTime);

                                } else {
                                    TblReportFormsVo tblReportFormsBO = new TblReportFormsVo();
                                    tblReportFormsBO.setOrganizationCode(orgCode);
                                    tblReportFormsBO.setStartTime(startTime);
                                    tblReportFormsBO.setEndTime(endTime);
                                    tblCountAndTimeDOS = tblReportFormsMapperDao.selectDeviceByTimeAndOrgCode(tblReportFormsBO);

                                }
                            }
                            break;
                    }
                    break;
                case "message":
                    switch (time) {
                        case "day1":
                            if (ORGCODE.equals(orgCode) || orgCode == null || orgCode == "") {
                                tblCountAndTimeDOS = tblReportFormsMapperDao.selectMessageEveryDay(meTableList, "");
                                if (CollectionUtils.isEmpty(tblCountAndTimeDOS)) {
                                }
                            } else {
                                TblReportFormsVo tblReportFormsBO = new TblReportFormsVo();
                                tblReportFormsBO.setOrganizationCode(orgCode);
                                tblCountAndTimeDOS = tblReportFormsMapperDao.selectMessageEveryDayByOrgCode(meTableList, tblReportFormsBO);
                                if (CollectionUtils.isEmpty(tblCountAndTimeDOS)) {

                                }
                            }
                            break;
                        case "week":
                            if (ORGCODE.equals(orgCode) || orgCode == null || orgCode == "") {
                                tblCountAndTimeDOS = tblReportFormsMapperDao.selectMessageEveryWeek(meTableList, "");
                                if (CollectionUtils.isEmpty(tblCountAndTimeDOS)) {
//                                resultDTO.setSuccess(false);
//                                resultDTO.setErrorDetail("查询每周注册用户量失败");
//                                resultDTO.setResultCode(ResultCode.PARAM_ERROR);
//                                return resultDTO;
                                }
                            } else {
                                TblReportFormsVo tblReportFormsBO = new TblReportFormsVo();
                                tblReportFormsBO.setOrganizationCode(orgCode);
                                tblCountAndTimeDOS = tblReportFormsMapperDao.selectMessageEveryWeekByOrgCode(meTableList, tblReportFormsBO);
                                if (CollectionUtils.isEmpty(tblCountAndTimeDOS)) {
//                                resultDTO.setSuccess(false);
//                                resultDTO.setErrorDetail("查询每周注册用户量失败");
//                                resultDTO.setResultCode(ResultCode.PARAM_ERROR);
//                                return resultDTO;
                                }
                            }
                            break;
                        case "month":

                            //获取月的用户量
                            if (ORGCODE.equals(orgCode) || orgCode == null || orgCode == "") {
                                tblCountAndTimeDOS = tblReportFormsMapperDao.selectMessageEveryMonth(meTableList, "");
                                if (CollectionUtils.isEmpty(tblCountAndTimeDOS)) {
//                                resultDTO.setSuccess(false);
//                                resultDTO.setErrorDetail("查询每月注册用户量失败");
//                                resultDTO.setResultCode(ResultCode.PARAM_ERROR);
//                                return resultDTO;
                                }
                            } else {
                                TblReportFormsVo tblReportFormsBO = new TblReportFormsVo();
                                tblReportFormsBO.setOrganizationCode(orgCode);
                                tblCountAndTimeDOS = tblReportFormsMapperDao.selectMessageEveryMonthByOrgCode(meTableList, tblReportFormsBO);
                                if (CollectionUtils.isEmpty(tblCountAndTimeDOS)) {
//                                resultDTO.setSuccess(false);
//                                resultDTO.setErrorDetail("查询每月注册用户量失败");
//                                resultDTO.setResultCode(ResultCode.PARAM_ERROR);
//                                return resultDTO;
                                }
                            }
                            break;

                        default:
                            if (StringUtils.isNotEmpty(time)) {
                                String[] timeStr = time.split("~");
                                String startTime = timeStr[0] + " 00:00:00";
                                String endTime = timeStr[1] + " 23:59:59";
                                if (ORGCODE.equals(orgCode) || orgCode == "" || orgCode == null) {
                                    tblCountAndTimeDOS = tblReportFormsMapperDao.selectMessageByTime(meTableList, startTime, endTime);

                                } else {
                                    TblReportFormsVo tblReportFormsBO = new TblReportFormsVo();
                                    tblReportFormsBO.setOrganizationCode(orgCode);
                                    tblReportFormsBO.setStartTime(startTime);
                                    tblReportFormsBO.setEndTime(endTime);
                                    tblCountAndTimeDOS = tblReportFormsMapperDao.selectMessageByTimeAndOrgCode(meTableList, tblReportFormsBO);

                                }
                            }
                            break;
                    }
                    break;
                case "alarm":
                    switch (time) {
                        case "day1":
                            if (ORGCODE.equals(orgCode) || orgCode == null || orgCode == "") {
                                tblCountAndTimeDOS = tblReportFormsMapperDao.selectAlarmEveryDay(seTableList, "");
                                if (CollectionUtils.isEmpty(tblCountAndTimeDOS)) {
                                }
                            } else {
                                TblReportFormsVo tblReportFormsBO = new TblReportFormsVo();
                                tblReportFormsBO.setOrganizationCode(orgCode);
                                tblReportFormsBO.setRelationType("0");
                                tblCountAndTimeDOS = tblReportFormsMapperDao.selectAlarmEveryDayByOrgCode(seTableList, tblReportFormsBO);
                                if (CollectionUtils.isEmpty(tblCountAndTimeDOS)) {

                                }
                            }
                            break;
                        case "week":
                            if (ORGCODE.equals(orgCode) || orgCode == null || orgCode == "") {
                                tblCountAndTimeDOS = tblReportFormsMapperDao.selectAlarmEveryWeek(seTableList, "");
                                if (CollectionUtils.isEmpty(tblCountAndTimeDOS)) {
//                                resultDTO.setSuccess(false);
//                                resultDTO.setErrorDetail("查询每周注册用户量失败");
//                                resultDTO.setResultCode(ResultCode.PARAM_ERROR);
//                                return resultDTO;
                                }
                            } else {
                                TblReportFormsVo tblReportFormsBO = new TblReportFormsVo();
                                tblReportFormsBO.setOrganizationCode(orgCode);
                                tblReportFormsBO.setRelationType("0");
                                tblCountAndTimeDOS = tblReportFormsMapperDao.selectAlarmEveryWeekByOrgCode(seTableList, tblReportFormsBO);
                                if (CollectionUtils.isEmpty(tblCountAndTimeDOS)) {
//                                resultDTO.setSuccess(false);
//                                resultDTO.setErrorDetail("查询每周注册用户量失败");
//                                resultDTO.setResultCode(ResultCode.PARAM_ERROR);
//                                return resultDTO;
                                }
                            }
                            break;
                        case "month":

                            //获取月的消息量
                            if (ORGCODE.equals(orgCode) || orgCode == null || orgCode == "") {
                                tblCountAndTimeDOS = tblReportFormsMapperDao.selectAlarmEveryMonth(seTableList, "");
                                if (CollectionUtils.isEmpty(tblCountAndTimeDOS)) {
//                                resultDTO.setSuccess(false);
//                                resultDTO.setErrorDetail("查询每月注册用户量失败");
//                                resultDTO.setResultCode(ResultCode.PARAM_ERROR);
//                                return resultDTO;
                                }
                            } else {
                                TblReportFormsVo tblReportFormsBO = new TblReportFormsVo();
                                tblReportFormsBO.setOrganizationCode(orgCode);
                                tblReportFormsBO.setRelationType("0");
                                tblCountAndTimeDOS = tblReportFormsMapperDao.selectAlarmEveryMonthByOrgCode(seTableList, tblReportFormsBO);
                                if (CollectionUtils.isEmpty(tblCountAndTimeDOS)) {
//                                resultDTO.setSuccess(false);
//                                resultDTO.setErrorDetail("查询每月注册用户量失败");
//                                resultDTO.setResultCode(ResultCode.PARAM_ERROR);
//                                return resultDTO;
                                }
                            }
                            break;
                        default:
                            if (StringUtils.isNotEmpty(time)) {
                                String[] timeStr = time.split("~");
                                String startTime = timeStr[0] + " 00:00:00";
                                String endTime = timeStr[1] + " 23:59:59";
                                if (ORGCODE.equals(orgCode) || orgCode == null || orgCode == "") {
                                    tblCountAndTimeDOS = tblReportFormsMapperDao.selectAlarmByTime(seTableList, startTime, endTime);

                                } else {
                                    TblReportFormsVo tblReportFormsBO = new TblReportFormsVo();
                                    tblReportFormsBO.setOrganizationCode(orgCode);
                                    tblReportFormsBO.setStartTime(startTime);
                                    tblReportFormsBO.setEndTime(endTime);
                                    tblCountAndTimeDOS = tblReportFormsMapperDao.selectAlarmByTimeAndOrgCode(seTableList, tblReportFormsBO);

                                }
                            }
                            break;
                    }
                    break;
                case "gateway":
                    switch (time) {
                        case "day1":
                            if (ORGCODE.equals(orgCode)) {
                                tblCountAndTimeDOS = tblReportFormsMapperDao.selectGateWayEveryDay("");
                                if (CollectionUtils.isEmpty(tblCountAndTimeDOS)) {
                                }
                            } else {
                                TblReportFormsVo tblReportFormsBO = new TblReportFormsVo();
                                tblReportFormsBO.setOrganizationCode(orgCode);
                                tblReportFormsBO.setRelationType("0");
                                tblCountAndTimeDOS = tblReportFormsMapperDao.selectGateWayEveryDayByOrgCode(tblReportFormsBO);
                                if (CollectionUtils.isEmpty(tblCountAndTimeDOS)) {

                                }
                            }
                            break;
                        case "week":
                            if (ORGCODE.equals(orgCode)) {
                                tblCountAndTimeDOS = tblReportFormsMapperDao.selectGateWayEveryWeek("");
                                if (CollectionUtils.isEmpty(tblCountAndTimeDOS)) {
//                                resultDTO.setSuccess(false);
//                                resultDTO.setErrorDetail("查询每周注册用户量失败");
//                                resultDTO.setResultCode(ResultCode.PARAM_ERROR);
//                                return resultDTO;
                                }
                            } else {
                                TblReportFormsVo tblReportFormsBO = new TblReportFormsVo();
                                tblReportFormsBO.setOrganizationCode(orgCode);
                                tblReportFormsBO.setRelationType("0");
                                tblCountAndTimeDOS = tblReportFormsMapperDao.selectGateWayEveryWeekByOrgCode(tblReportFormsBO);
                                if (CollectionUtils.isEmpty(tblCountAndTimeDOS)) {
//                                resultDTO.setSuccess(false);
//                                resultDTO.setErrorDetail("查询每周注册用户量失败");
//                                resultDTO.setResultCode(ResultCode.PARAM_ERROR);
//                                return resultDTO;
                                }
                            }
                            break;
                        case "month":

                            //获取月的网关数量
                            if (ORGCODE.equals(orgCode)) {
                                tblCountAndTimeDOS = tblReportFormsMapperDao.selectGateWayEveryMonth("");
                                if (CollectionUtils.isEmpty(tblCountAndTimeDOS)) {
//                                resultDTO.setSuccess(false);
//                                resultDTO.setErrorDetail("查询每月注册用户量失败");
//                                resultDTO.setResultCode(ResultCode.PARAM_ERROR);
//                                return resultDTO;
                                }
                            } else {
                                TblReportFormsVo tblReportFormsBO = new TblReportFormsVo();
                                tblReportFormsBO.setOrganizationCode(orgCode);
                                tblReportFormsBO.setRelationType("0");
                                tblCountAndTimeDOS = tblReportFormsMapperDao.selectGateWayEveryMonthByOrgCode(tblReportFormsBO);
                                if (CollectionUtils.isEmpty(tblCountAndTimeDOS)) {
//                                resultDTO.setSuccess(false);
//                                resultDTO.setErrorDetail("查询每月注册用户量失败");
//                                resultDTO.setResultCode(ResultCode.PARAM_ERROR);
//                                return resultDTO;
                                }
                            }
                            break;
                        default:
                            if (StringUtils.isNotEmpty(time)) {
                                String[] timeStr = time.split("~");
                                String startTime = timeStr[0] + " 00:00:00";
                                String endTime = timeStr[1] + " 23:59:59";
                                if (ORGCODE.equals(orgCode)) {
                                    tblCountAndTimeDOS = tblReportFormsMapperDao.selectGateWayByTime(startTime, endTime);

                                } else {
                                    TblReportFormsVo tblReportFormsBO = new TblReportFormsVo();
                                    tblReportFormsBO.setOrganizationCode(orgCode);
                                    tblReportFormsBO.setStartTime(startTime);
                                    tblReportFormsBO.setEndTime(endTime);
                                    tblCountAndTimeDOS = tblReportFormsMapperDao.selectGateWayByTimeAndOrgCode(tblReportFormsBO);

                                }
                            }
                            break;
                    }
                    break;
                default:
                    break;
            }

        } catch (Exception e) {
            System.out.println("ReportFormsFuncation方法出现异常，异常内容为：" + e);
        }
        return tblCountAndTimeDOS;
    }


    /**
     * 获取一天中的总数注册用户数
     *
     * @param query
     * @return
     */
    @Override
    public BatchResultDTO<TblCountAndTimeDO> getRegisterUserEveryWeek(TblReportFormsVo query) {
        BatchResultDTO<TblCountAndTimeDO> result = new BatchResultDTO<TblCountAndTimeDO>();

        try {
            List<TblCountAndTimeDO> appUserDOList = tblReportFormsMapperDao.selectAppUseCountEveryWeek(query);
            if (appUserDOList.size() < 0) {
                result.setSuccess(false);
                result.setErrorDetail("查询出错");
            }
            result.setSuccess(true);
            result.setModule(appUserDOList);
            result.setResultCode(ResultCode.SUCCESS);
        } catch (Exception e) {
            result.setSuccess(false);
            result.setResultCode(ResultCode.SYS_ERROR);
            result.setErrorDetail("获取新用户量系统异常！");
        }
        return result;
    }

    /**
     * 获取一周注册总数，显示七周
     *
     * @param query
     * @return
     */
    @Override
    public BatchResultDTO<TblCountAndTimeDO> getDeviceCountEveryWeek(TblReportFormsVo query) {
        BatchResultDTO<TblCountAndTimeDO> result = new BatchResultDTO<TblCountAndTimeDO>();

        try {
            List<TblCountAndTimeDO> appUserDOList = tblReportFormsMapperDao.selectDeviceCountEveryWeek(query);
            if (appUserDOList.size() < 0) {
                result.setSuccess(false);
                result.setErrorDetail("查询出错");
            }
            result.setSuccess(true);
            result.setModule(appUserDOList);
            result.setResultCode(ResultCode.SUCCESS);
        } catch (Exception e) {
            result.setSuccess(false);
            result.setResultCode(ResultCode.SYS_ERROR);
            result.setErrorDetail("获取新用户量系统异常！");
        }
        return result;
    }

    @Override
    public BatchResultDTO<TblCountAndTimeDO> getGateWayCountEveryWeek(TblReportFormsVo query) {
        BatchResultDTO<TblCountAndTimeDO> result = new BatchResultDTO<TblCountAndTimeDO>();

        try {
            List<TblCountAndTimeDO> appUserDOList = tblReportFormsMapperDao.selectGateWayCountEveryWeek(query);
            if (appUserDOList.size() < 0) {
                result.setSuccess(false);
                result.setErrorDetail("查询出错");
            }
            result.setSuccess(true);
            result.setModule(appUserDOList);
            result.setResultCode(ResultCode.SUCCESS);
        } catch (Exception e) {
            result.setSuccess(false);
            result.setResultCode(ResultCode.SYS_ERROR);
            result.setErrorDetail("获取新用户量系统异常！");
        }
        return result;
    }
}
